﻿using System;
using System.IO;

class ExtractTextWithoutTagsXMLFile 
{
    static void Main()
    {
        //Exercise 10.
        //Write a program that extracts from given XML file all the text without the tags. Example:

        //<?xml version="1.0">
        //<student>
        //<name>Pesho</name>
        //<age>21</age>
        //<interests count="3">
        //  <interest> Games</instrest>
        //  <interest>C#</instrest>
        //  <interest> Java</instrest>
        //</interests>
        //</student>

        StreamReader reader = new StreamReader(@"C:\Users\Toni\Desktop\Test XML.txt");

        using (reader)
        {
            for (int i; (i = reader.Read()) != -1; ) // reads each char
            {
                if (i == '>') 
                {
                    string text = String.Empty;

                    while ((i = reader.Read()) != -1 && i != '<')
                    {
                        text += (char)i;
                    }

                    if (!String.IsNullOrWhiteSpace(text))
                    {
                        Console.WriteLine(text.Trim());
                    }
                }
            }
           
        }

    }
}

